#include<iostream>
#include<vector>
using namespace std;
int maxArea(vector<int> &height) {
    int res = 0;
    for (int i = 0; i < height.size() - 1; i++) {
        for (int j = i + 1; j < height.size(); j++) {
            int x = j - i;
            int y = height[i] < height[j] ? height[i] : height[j];
            res = res > x*y ? res : x*y;
        }
    }
    return res;
}

int main() {
    vector<int> height = {1,8,6,2,5,4,8,3,7};
    int res = maxArea(height);

    cout << res << endl;
}
